<?php
/**
 * Created by PhpStorm.
 * User: changshuiwang
 * Date: 2016/7/25
 * Time: 16:31
 */

namespace common\models;
use yii;

class Teacher extends TeacBase
{
    //public $username;
    //public $password_hash;
    //public $password_hash2;

    public function scenarios()
    {
        return [
            'add' => ['username', 'password_hash', 'status'],
            'delete' => ['status'],
        ];
    }

    public function rules()
    {
        return [
            [['username', 'password_hash'], 'required', 'message'=>'用户名密码不能为空', 'on' =>['add']],
            ['username','unique','message'=>'用户名已占用','on'=>['add']],
            ['status','default','value' => 10,'on'=>['add']],
        ];
    }
    public static function tableName()
    {
        return 'user';
    }

    public function attributeLabels()
    {
        return [
            'id' => '教师id',
        ];
    }

    public static function test()
    {
        var_dump(Teacher::find()->all());
    }

    public static function getAllTeacher()
    {
        return Teacher::find()->where(['type'=>2]);
        //var_dump(Teacher::find()->where(['type'=>2])->all());die;
    }
}